package cn.jobstart.common;

import com.alibaba.fastjson.JSONObject;

import java.util.HashMap;
import java.util.Map;

/**
 * @author sunke
 * @version 1.0
 * @Description 短信
 * @date 2023-08-09 23:25
 */
public class SmsUtils {


    public static void main(String[] args) {


        sendMsg("15990084484","1234445");

    }

    public static JSONObject sendMsg(String phone, String content) {

        String url = "https://gyytz.market.alicloudapi.com/sms/smsSend";

        String method = "POST";
        String appcode = "04f63c07214d41899812b815aef2b8a3";
        Map<String, String> headers = new HashMap<String, String>();
        //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
        headers.put("Authorization", "APPCODE " + appcode);


        Map<String, String> querys = new HashMap<String, String>();
        querys.put("mobile", phone);
        querys.put("param", "**code**:"+content+",**minute**:5");

        //smsSignId（短信前缀）和templateId（短信模板），可登录国阳云控制台自助申请。参考文档：http://help.guoyangyun.com/Problem/Qm.html

        querys.put("smsSignId", "2204181a985945d192ede2de14851afd");
        querys.put("templateId", "0092b0c07d9b41cc8f9b5f9b6077fa7e");
        Map<String, String> bodys = new HashMap<String, String>();


        String res = HttpTookit.doPost(url, querys, headers);
        System.out.println(res);
        return JSONObject.parseObject(res);


    }

}
